package publicate;

import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class PublicateResultsPanel extends javax.swing.JPanel
{
    public void addButtonActionListener( ActionListener l )
    {
        checkHashButton.addActionListener( l );
    }

    public String getHash()
    {
        if( checkHashTextField.getText().equals( "" ) )
        {
            hashStatusLabel.setText( "SIEDZE NA KONIU" );
        }
        return checkHashTextField.getText();
    }

    public void setHashInfo( String text )
    {
        hashStatusLabel.setText( text );
    }

    public void setInfoText( String text )
    {
        System.out.println( "PANEL DOSTAL " + text );
        String message = "<html>" + text + "</html>";
        resultsLabel.setText( message );
    }

    public PublicateResultsPanel()
    {
        initComponents();
    }

    private void initComponents()
    {
        jLabel1 = new javax.swing.JLabel();
        hashStatusLabel = new javax.swing.JLabel();
        checkHashTextField = new javax.swing.JTextField();
        checkHashButton = new javax.swing.JButton();
        resultsLabel = new javax.swing.JLabel();
        jLabel1.setText( "Type in hash of your vote to check if your vote was counted." );
        checkHashButton.setText( "Check" );
        resultsLabel.setText( "<html>Election results... And the winner is...<br>" );
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout( this );
        this.setLayout( layout );
        layout.setHorizontalGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup(
            layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                .addComponent( jLabel1 )
                                .addGroup(
                                    layout.createSequentialGroup()
                                            .addComponent( checkHashTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 179,
                                                javax.swing.GroupLayout.PREFERRED_SIZE ).addGap( 18, 18, 18 )
                                            .addComponent( checkHashButton )
                                            .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
                                            .addComponent( hashStatusLabel ) )
                                .addComponent( resultsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE ) ).addContainerGap( 36, Short.MAX_VALUE ) ) );
        layout.setVerticalGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING ).addGroup(
            layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent( jLabel1 )
                    .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED )
                    .addGroup(
                        layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
                                .addComponent( checkHashTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
                                .addComponent( checkHashButton ).addComponent( hashStatusLabel ) )
                    .addGap( 18, 18, 18 )
                    .addComponent( resultsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE ).addContainerGap( 195, Short.MAX_VALUE ) ) );
    }// </editor-fold>

    private JLabel jLabel1;
    private JLabel hashStatusLabel;
    private JLabel resultsLabel;
    private JTextField checkHashTextField;
    private JButton checkHashButton;
}
